#include "BossEntity.h"
BossEntity::BossEntity(int id, int type, double x, double y)
{
	gunTopLeftEntity = new GunTopLeftEntity(id, type, x, y);
	gunTopRightentity = new GunTopRightEntity(id, type, x, y);
	gunBottomEntity = new GunBottomEntity(id, type, x, y);

	_data = new BossData(id, _ID_ARMY_BOSS_1, x, y, -1);
	_data->subRect->push_back(gunTopLeftEntity->getAbstractData()->getRect());
	_data->subRect->push_back(gunTopRightentity->getAbstractData()->getRect());
	_data->subRect->push_back(gunBottomEntity->getAbstractData()->getRect());
}

/*Update object*/
void BossEntity::update(long time)
{
	gunTopLeftEntity->update(time);
	gunTopRightentity->update(time);
	gunBottomEntity->update(time);
	if (gunTopLeftEntity->getAbstractData()->isDead && gunTopRightentity->getAbstractData()->isDead) {
		gunBottomEntity->getAbstractData()->canInteract = true;
	}
}

/*Draw object*/
void BossEntity::draw(long time)
{
	gunTopLeftEntity->draw(time);
	gunTopRightentity->draw(time);
	gunBottomEntity->draw(time);
}

/*Return object data*/
AbstractData* BossEntity::getAbstractData()
{
	return _data;
}

/*update data*/
void BossEntity::updateData(int action, int input)
{
	if (action == ACTIONS_IS_HURT) {
		int index = input / 10;
		int dam = input % 10;
		switch(index) {
		case 0: gunTopLeftEntity->updateData(action, dam); break;
		case 1: gunTopRightentity->updateData(action, dam); break;
		case 2: gunBottomEntity->updateData(action, dam); break;
		}
	}
}

AbstractEntity* BossEntity::getSubEntity(int index) {
	switch (index) {
	case 1: return gunTopRightentity;
	case 2: return gunBottomEntity;
	default: return gunTopLeftEntity;
	}
}

BossEntity::~BossEntity()
{

}